package org.yuyao.biz1.controller;

import io.micrometer.tracing.Span;
import io.micrometer.tracing.Tracer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("zipKee")
public class ZipKeeTestController {

    private final Tracer tracer;

    public ZipKeeTestController(Tracer tracer) {
        this.tracer = tracer;
    }

    @GetMapping("/demo")
    public String demo() {
        // 创建自定义 Span
        Span span = tracer.nextSpan().name("custom-operation").start();
        try (Tracer.SpanInScope scope = tracer.withSpan(span)) {
            // 业务逻辑
            return "Hello, Micrometer Tracing!";
        } finally {
            span.end();
        }
    }

}
